<?php
include_once('../public/header.php');
$config = include('../../public/config/config.php');
include('../../public/func/db.php');
$table = 'article';
$res = select($config,$table);
// var_dump($res);die;
foreach($res as $k=>$v){
    $author = select($config,'user','where id='.$v['uid']);
    $res[$k]['uid'] = $author[0]['nickname'];
    $category = select($config,'category','where id='.$v['cid']);
    $res[$k]['cid'] = $category[0]['title'];
}
// var_dump($res);die;
?>
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/admin/article/index.php">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">文章列表</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="/jscss/admin/design/index" method="post">
                    <table class="search-tab">
                        <tr>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="关键字" name="keywords" value="" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="/admin/article/add.php"><i class="icon-font"></i>新增文章</a>
                        <a id="batchDel" href="javascript:void(0)"><i class="icon-font"></i>批量删除</a>
                        <a id="updateOrd" href="javascript:void(0)"><i class="icon-font"></i>更新排序</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                            <th>ID</th>
                            <th>标题</th>
                            <th>所属分类</th>
                            <th>配图</th>
                            <th>作者</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        <?php
                            foreach($res as $k=>$v){
                                echo '<tr>';
                                echo '<td class="tc"><input name="id[]" value="59" type="checkbox"></td>';
                                echo '<td>'.$v['id'].'</td>';
                                echo '<td>'.$v['title'].'</td>';
                                echo '<td>'.$v['cid'].'</td>';
                                echo '<td><img width="80" src="/public/upload/'.$v['pic'].'"></td>';
                                echo '<td>'.$v['uid'].'</td>';
                                echo '<td>'.date('Y-m-d H:i:s',$v['ctime']).'</td>';
                                echo '<td><a class="link-update" href="/admin/article/update.php?id='.$v['id'].'">修改</a>/<a class="link-del" id="'.$v['id'].'" href="#">删除</a></td>';
                                echo '</tr>';
                            }
                        ?>
                    </table>
                    <div class="list-page"> 2 条 1/1 页</div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
<script>
    $(".link-del").click(function(){
        var bool = confirm('确定要删除吗？');
        if(bool){
            var id = $(this).attr('id');
            window.location.href='/admin/article/del.php?id='+id;
        }
    })
</script>
</body>
</html>